home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Bank smakow / BankSmakow.air / BankSmakow.swf / scripts / mx / utils / NameUtil.as < prev    next >
Text File  |  2009-12-16  |  2KB  |  79 lines

  1. package mx.utils
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.utils.getQualifiedClassName;
  5.    import mx.core.IRepeaterClient;
  6.    import mx.core.mx_internal;
  7.    
  8.    use namespace mx_internal;
  9.    
  10.    public class NameUtil
  11.    {
  12.       
  13.       mx_internal static const VERSION:String = "3.5.0.12683";
  14.       
  15.       private static var counter:int = 0;
  16.        
  17.       
  18.       public function NameUtil()
  19.       {
  20.          super();
  21.       }
  22.       
  23.       public static function displayObjectToString(param1:DisplayObject) : String
  24.       {
  25.          var result:String = null;
  26.          var o:DisplayObject = null;
  27.          var s:String = null;
  28.          var indices:Array = null;
  29.          var displayObject:DisplayObject = param1;
  30.          try
  31.          {
  32.             o = displayObject;
  33.             while(o != null)
  34.             {
  35.                if(o.parent && o.stage && o.parent == o.stage)
  36.                {
  37.                   break;
  38.                }
  39.                s = o.name;
  40.                if(o is IRepeaterClient)
  41.                {
  42.                   indices = IRepeaterClient(o).instanceIndices;
  43.                   if(indices)
  44.                   {
  45.                      s += "[" + indices.join("][") + "]";
  46.                   }
  47.                }
  48.                result = result == null ? s : s + "." + result;
  49.                o = o.parent;
  50.             }
  51.          }
  52.          catch(e:SecurityError)
  53.          {
  54.          }
  55.          return result;
  56.       }
  57.       
  58.       public static function createUniqueName(param1:Object) : String
  59.       {
  60.          if(!param1)
  61.          {
  62.             return null;
  63.          }
  64.          var _loc2_:* = getQualifiedClassName(param1);
  65.          var _loc3_:int = _loc2_.indexOf("::");
  66.          if(_loc3_ != -1)
  67.          {
  68.             _loc2_ = _loc2_.substr(_loc3_ + 2);
  69.          }
  70.          var _loc4_:int;
  71.          if((_loc4_ = _loc2_.charCodeAt(_loc2_.length - 1)) >= 48 && _loc4_ <= 57)
  72.          {
  73.             _loc2_ += "_";
  74.          }
  75.          return _loc2_ + counter++;
  76.       }
  77.    }
  78. }
  79.